package com.bds.wm.utils;

import org.apache.log4j.Logger;

/**
 * Created by guoyu on 2018/5/16.
 */
public class CheckParams {
    private static Logger LOGGER = Logger.getLogger(CheckParams.class);

    public static Integer checkIfIntAndReturn(String s) {
        try {
            return Integer.parseInt(s.replaceAll("-", ""));
        } catch (Exception e) {
            LOGGER.info("整型参数异常", e);
            return null;
        }
    }

    public static Double checkIfDoubleAndReturn(String s) {
        try {
            return Double.parseDouble(s.replaceAll("-", ""));
        } catch (Exception e) {
            LOGGER.info("浮点型参数异常", e);
            return null;
        }
    }

    public static Float checkIfFloatAndReturn(String s) {
        try {
            return Float.parseFloat(s.replaceAll("-", ""));
        } catch (Exception e) {
            LOGGER.info("浮点型参数异常", e);
            return null;
        }
    }
}
